package com.ruoyi.ysg.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ysg.domain.YsgTeacherUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ysg.mapper.YsgTeacherMapper;
import com.ruoyi.ysg.domain.YsgTeacher;
import com.ruoyi.ysg.service.IYsgTeacherService;

/**
 * 教师管理Service业务层处理
 *
 * @author xsz
 * @date 2025-09-24
 */
@Service("YsgTeacherService")
public class YsgTeacherServiceImpl implements IYsgTeacherService
{
    @Autowired
    private YsgTeacherMapper ysgTeacherMapper;

    /**
     * 查询教师管理
     *
     * @param id 教师管理主键
     * @return 教师管理
     */
    @Override
    public YsgTeacher selectYsgTeacherById(Long id)
    {
        return ysgTeacherMapper.selectYsgTeacherById(id);
    }

    /**
     * 查询教师管理列表
     *
     * @param ysgTeacher 教师管理
     * @return 教师管理
     */
    @Override
    public List<YsgTeacher> selectYsgTeacherList(YsgTeacher ysgTeacher)
    {
        return ysgTeacherMapper.selectYsgTeacherList(ysgTeacher);
    }

    /**
     * 新增教师管理
     *
     * @param ysgTeacher 教师管理
     * @return 结果
     */
    @Override
    public int insertYsgTeacher(YsgTeacher ysgTeacher)
    {
        ysgTeacher.setCreateTime(DateUtils.getNowDate());
        return ysgTeacherMapper.insertYsgTeacher(ysgTeacher);
    }

    /**
     * 修改教师管理
     *
     * @param ysgTeacher 教师管理
     * @return 结果
     */
    @Override
    public int updateYsgTeacher(YsgTeacher ysgTeacher)
    {
        ysgTeacher.setUpdateTime(DateUtils.getNowDate());
        return ysgTeacherMapper.updateYsgTeacher(ysgTeacher);
    }

    /**
     * 批量删除教师管理
     *
     * @param ids 需要删除的教师管理主键
     * @return 结果
     */
    @Override
    public int deleteYsgTeacherByIds(Long[] ids)
    {
        return ysgTeacherMapper.deleteYsgTeacherByIds(ids);
    }

    /**
     * 删除教师管理信息
     *
     * @param id 教师管理主键
     * @return 结果
     */
    @Override
    public int deleteYsgTeacherById(Long id)
    {
        return ysgTeacherMapper.deleteYsgTeacherById(id);
    }

    @Override
    public List<SysUser> unAssociatedUserList(SysUser user) {
        return ysgTeacherMapper.unAssociatedUserList(user);
    }

    @Override
    public List<SysUser> getAssociatedUser(String teacherId) {
        return ysgTeacherMapper.associatedUserList(teacherId);
    }

    @Override
    public int associate(YsgTeacherUser ysgTeacherUser) {
        return ysgTeacherMapper.insertTeacherUser(ysgTeacherUser);
    }

    @Override
    public int insertunAssociateYsgTeacher(YsgTeacherUser ysgTeacherUser) {
        return ysgTeacherMapper.deleteTeacherUser(ysgTeacherUser);
    }

    public YsgTeacher getTeacherBySysUserId(Long userId) {
        return ysgTeacherMapper.getTeacherBySysUserId(userId);
    }
}
